export default{
	state: {
		token:'', //当前用户的token
		userInfo: {},//当前用户的信息
		status:false //判断是否是登录状态
	},
	mutations: {
		setToken( state , token ){
			state.token = token;
		},
		setUserInfo(state,userInfo){
			//如果能获得用户信息，就修改状态和值
			if(  userInfo?.username ){
				state.userInfo = userInfo;
				state.status = true;
			}else{
				state.userInfo = {};
				state.status = false;
			}
		},
		clearUser( state ){
			state.token = '';
			state.userInfo= {};
			state.status=false; //判断是否是登录状态
		}
	},
}